import request from '@/utils/request'

/**
 * 出库分页查询
 * @param {*} data = {pageNo: 0, pageSize: 0, param: {likeName, storageType(服务出库), storeId}}
 */
export function pageList(form, pageSize, currentPage) {
  const data = {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  }
  return request.post('/sq/brandOutStorage/page', data)
}

/**
 * 精品分页查询
 * @param {*} data = {pageNo: 0, pageSize: 0, param: {outStorageId}}
 */
export function partsPage(form, pageSize, currentPage) {
  const data = {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  }
  return request.post('/sq/brandOutStorage/partsPage', data)
}

/**
 * 精品分页查询
 * @param {*} data = {pageNo: 0, pageSize: 0, param: {likeName, outStorageId, partsUnit(精品类别字典值),status}}
 */
export function partsDetailPage(form, pageSize, currentPage) {
  const data = {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  }
  return request.post('/sq/brandOutStorage/partsDetailPage', data)
}

/**
 * 新增出库
 * @param {*} data
 */
export function save(data) {
  return request.post('/sq/brandOutStorage/save', data)
}

/**
 * 更新出库
 * @param {*} data
 */
export function update(data) {
  return request.put('/sq/brandOutStorage/save', data)
}

/**
 * 删除出库
 * @param {*} id
 */
export function deleteById(id) {
  return request.delete(`/sq/brandOutStorage/del/${id}`)
}

/**
 * 编辑出库详情
 * @param {*} id
 */
export function editDetailById(id) {
  return request.get(`/sq/brandOutStorage/findById/${id}`)
}

/**
 * 出库详情
 * @param {*} id
 */
export function detailById(id) {
  return request.get(`/sq/brandOutStorage/detail/${id}`)
}

/**
 * 获取出库编号
 */
export function getStorageCode() {
  return request.get(`/sq/brandOutStorage/getStorageCode`)
}

/**
 * 查询来源单号
 */
export function findSourceCode(outStorageType, sourceCode) {
  return request.get(`/sq/brandOutStorage/findSourceCode/${outStorageType}/${sourceCode}`)
}

